package com.vne.skyemart.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "groups",catalog = "skyemart_db")
public class Groups {

	@Id
	@GeneratedValue
	@Column(name  = "GroupID", nullable = false)
	private int groupID;

	@Column(name = "GroupName", nullable = false, length = 50)
	private String groupName;

	@Column(name = "Description", length = 250)
	private String description;

	@Column(name = "CreatedBy", nullable = false, length = 10)
	private int createdBy;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "CreatedDate", nullable = false)
	private Date createdDate;
	
	@Column(name = "ModifiedBy", length = 10, nullable = true)
	private int modifiedBy;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "ModifiedDate")
	private Date modifiedDate;
	
	@Column(name = "IsDeleted", nullable = false, length = 1)
	private String isDeleted;
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.groups")
	private Set<Permission> permissions = new HashSet<Permission>(0);

	@ManyToMany(fetch = FetchType.LAZY, mappedBy = "groups")
	private Set<ADUser> adUsers = new HashSet<ADUser>();

	public Groups() {}
	
	public Groups(int groupID, String groupName, String description,
			int createdBy, Date createdDate, int modifiedBy, Date modifiedDate,
			String isDeleted) {
		this.groupID = groupID;
		this.groupName = groupName;
		this.description = description;
		this.createdBy = createdBy;
		this.createdDate = createdDate;
		this.modifiedBy = modifiedBy;
		this.modifiedDate = modifiedDate;
		this.isDeleted = isDeleted;
	}

	public Groups(int groupID, String groupName, String description,
			int createdBy, Date createdDate, int modifiedBy, Date modifiedDate,
			String isDeleted, Set<Permission> permissions, Set<ADUser> adUsers) {
		this.groupID = groupID;
		this.groupName = groupName;
		this.description = description;
		this.createdBy = createdBy;
		this.createdDate = createdDate;
		this.modifiedBy = modifiedBy;
		this.modifiedDate = modifiedDate;
		this.isDeleted = isDeleted;
		this.permissions = permissions;
		this.adUsers = adUsers;
	}

	public int getGroupID() {
		return groupID;
	}

	public void setGroupID(int groupID) {
		this.groupID = groupID;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(int createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public int getModifiedBy() {
		return modifiedBy;
	}

	public void setModifiedBy(int modifiedBy) {
		this.modifiedBy = modifiedBy;
	}

	public Date getModifiedDate() {
		return modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		this.modifiedDate = modifiedDate;
	}

	public String getIsDeleted() {
		return isDeleted;
	}
	
	public void setIsDeleted(String isDeleted) {
		this.isDeleted = isDeleted;
	}
	
	
	public Set<Permission> getPermissions() {
		return permissions;
	}

	public void setPermissions(Set<Permission> permissions) {
		this.permissions = permissions;
	}
	
	public Set<ADUser> getAdUsers() {
		return adUsers;
	}

	public void setAdUsers(Set<ADUser> adUsers) {
		this.adUsers = adUsers;
	}
}
